﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Classes.effects {
    import Engine.Classes.*;
    import flash.display.*;
    import Classes.*;

    public class MasteryStagePickEffect extends StagePickEffect {

        public static const PICK_MASTERY:String = "guitarpicMastery";
        public static const MASTERY_INDICATOR_ON:String = "masteryStarIndicator";
        public static const MAX_MASTERY_LEVEL:int = 4;

        protected var m_masteryBar:Sprite;

        public function MasteryStagePickEffect(_arg1:MapResource){
            super(_arg1);
        }
        override public function cleanUp():void{
            super.cleanUp();
            if (this.m_masteryBar){
                removeFromParent(this.m_masteryBar);
                this.m_masteryBar = null;
            };
        }
        override protected function fadeCallback():void{
            m_mapResource.setShowUpgradeArrow(false);
            super.fadeCallback();
        }
        override protected function setPickImage(_arg1:String, _arg2:String):void{
            var _local7:IsoRect;
            var _local8:Number;
            var _local9:int;
            var _local10:Number;
            var _local11:Sprite;
            var _local12:Bitmap;
            var _local13:Bitmap;
            removeFromParent(m_currentPickImage);
            removeFromParent(m_currentModifierImage);
            removeFromParent(m_guitarPickAnimation);
            removeFromParent(m_ministarImage);
            removeFromParent(this.m_masteryBar);
            var _local3:Boolean = ((((m_mapResource.canCountUpgradeActions()) || (m_mapResource.canShowAlternativeUpgradeToolTip()))) && (m_mapResource.canShowUpgradeToolTips()));
            var _local4:String = (_local3) ? PICK_MASTERY : PICK_SHINE;
            var _local5 = -1;
            var _local6:Item = m_mapResource.getItem();
            if (_local3){
                _local5 = _local6.level;
            };
            if (_arg1){
                m_guitarPickAnimation = (getImage(_local4) as AnimatedBitmap);
                m_guitarPickAnimation.x = ((-(m_guitarPickAnimation.width) >> 1) + 1);
                if (_arg1 == PICK_4){
                    m_guitarPickAnimation.x = ((-(m_guitarPickAnimation.width) >> 1) + 1.5);
                };
                m_guitarPickAnimation.y = ((-(m_guitarPickAnimation.height) >> 1) + 3);
                m_currentPickImage = (getImage(_arg1) as DisplayObject);
                m_currentPickImage.x = (-(m_currentPickImage.width) * 0.5);
                m_currentPickImage.y = ((-(m_currentPickImage.height) * 0.5) + (_local3) ? 1.5 : 0);
                m_currentModifierImage = ((_arg2)!=null) ? (getImage(_arg2) as DisplayObject) : new Sprite();
                m_currentModifierImage.x = (-(m_currentModifierImage.width) * 0.5);
                m_currentModifierImage.y = (-(m_currentModifierImage.height) * 1.5);
                m_ministarImage = (getImage(MINI_STAR) as DisplayObject);
                m_ministarImage.x = (m_currentPickImage.x + (m_currentPickImage.width * 0.6));
                m_ministarImage.y = (m_currentPickImage.y + (m_currentPickImage.height * 0.1));
                if (!m_showMinistar){
                    m_ministarImage.visible = false;
                };
                _local7 = IsoRect.getIsoRectFromSize(m_mapResource.getReference().getSize());
                m_effectX = _local7.bottom.x;
                m_effectY = (_local7.top.y + (m_guitarPickAnimation.height / 2));
                m_guitarPickAnimation.stop();
                this.m_masteryBar = new Sprite();
                if (_local3){
                    _local9 = 0;
                    _local10 = 1;
                    while (_local9 < _local5) {
                        _local11 = new Sprite();
                        _local12 = (getImage(MASTERY_INDICATOR_ON) as Bitmap);
                        _local13 = new Bitmap(_local12.bitmapData);
                        _local11.addChild(_local13);
                        _local11.x = (_local10 + (_local9 * (_local11.width - 1)));
                        this.m_masteryBar.addChild(_local11);
                        _local9++;
                    };
                };
                this.m_masteryBar.x = (-(this.m_masteryBar.width) * 0.5);
                this.m_masteryBar.y = m_guitarPickAnimation.y;
                this.addChild(m_guitarPickAnimation);
                this.addChild(m_currentPickImage);
                this.addChild(m_currentModifierImage);
                this.addChild(m_ministarImage);
                this.addChild(this.m_masteryBar);
                _local8 = PICK_Y_OFFSET;
                this.y = ((m_effectY + _local8) - PICK_FLOAT_DISTANCE);
                this.x = m_effectX;
            };
            if (m_floatActive){
                float();
            } else {
                if (m_queuedActive){
                    queuedFloat();
                };
            };
        }

    }
}//package Classes.effects 
